package com.platform.modules.mch.task;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.platform.modules.mall.entity.MallGoodsEntity;
import com.platform.modules.mall.service.MallGoodsService;
import com.platform.modules.mch.service.MchGoodsExtendService;
import com.platform.modules.mch.service.MchGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品同步任务
 */
@Slf4j
@Component("mchGoodsTask")
public class MchGoodsTask {

    @Resource
    private MchGoodsService mchGoodsService;
    @Resource
    private MallGoodsService goodsService;
    @Resource
    private MchGoodsExtendService goodsExtendService;

    /**
     * 第三方平台商品同步
     */
    public void goodsSync() {
        // 查询当前同步的全部商品 LL
        List<String> ids = goodsService.listObjs(new LambdaQueryWrapper<MallGoodsEntity>()
                .select(MallGoodsEntity::getId)
                .eq(MallGoodsEntity::getGoodsType,MallGoodsEntity.GoodsType.LL.ordinal())
                , Object::toString);
        // 通过ID查询联联商品
        mchGoodsService.syncGoods(null,ids);
    }

}
